<?php include 'application/views/header.php' ?>
<h4 class="page-title">Hình ảnh</h4>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm hình ảnh" />
</div>
<table width="100%" class="list list-picture">
    <tr>
        <th>STT</th>
        <th>Thên hình</th>
        <th>Hình ảnh</th>
        <th>Sản phẩm</th>
        <th>Thao tác</th>
    </tr>
    <?php $index = 1 ?>
    <?php foreach($Pictures as $picture): ?>
    <tr>    
       <td><?php echo $index++ ?></td>
       <td><?php echo $picture['PictureName'] ?></td>
       <td><img height="50px" src="<?php echo $this->config->item('base_download') ?>/pictures/<?php echo $picture['PictureLink'] ?>"/></td>
       <td><?php echo $picture['ProductName'] ?></td>
       <td>
             <a href="#">
                <div class="actDelete" pictureId="<?php echo $picture['PictureId'] ?>">Edit</div>
            </a>
       </td>
    </tr>
    <?php endforeach; ?>
</table>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm hình ảnh" />
</div>
<?php include 'application/views/footer.php' ?>

<script>
$('.btnAdd').click(function(){
    window.location.href = '<?php echo base_url() ?>picture/add.html'; 
});
$('.actDelete').click(function(){
    var pictureId = $(this).attr('pictureId');
    if(confirm("Bạn có muốn xóa không?")){
        window.location.href = '<?php echo base_url() ?>picture/delete/'+pictureId;
    }
    return false;
});
</script>